package com.atguigu.gulimall.mudan.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.atguigu.gulimall.mudan.entity.LegendEntity;
import com.atguigu.gulimall.mudan.service.LegendService;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;



/**
 * 
 *
 * @author yashu
 * @email 2377311752@qq.com
 * @date 2021-06-17 20:31:18
 */
@RestController
@RequestMapping("mudan/legend")
public class LegendController {
    @Autowired
    private LegendService legendService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("mudan:legend:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = legendService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{peonyLegendId}")
    //@RequiresPermissions("mudan:legend:info")
    public R info(@PathVariable("peonyLegendId") Integer peonyLegendId){
		LegendEntity legend = legendService.getById(peonyLegendId);

        return R.ok().put("legend", legend);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("mudan:legend:save")
    public R save(@RequestBody LegendEntity legend){
		legendService.save(legend);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("mudan:legend:update")
    public R update(@RequestBody LegendEntity legend){
		legendService.updateById(legend);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("mudan:legend:delete")
    public R delete(@RequestBody Integer[] peonyLegendIds){
		legendService.removeByIds(Arrays.asList(peonyLegendIds));

        return R.ok();
    }

}
